package com.lg.partition15;

import java.io.*;
import java.util.Arrays;

/**
 * @author `RKC`
 * @date 2022/3/17 9:51
 */
public class P1441砝码称重 {

    private static final int N = 21, M = 2010;
    private static int[] a = new int[N];
    private static boolean[] st = new boolean[N], f = new boolean[M];
    private static int n, m, ans = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        n = Integer.parseInt(ss[0]);
        m = Integer.parseInt(ss[1]);
        ss = reader.readLine().split(" ");
        for (int i = 1; i <= n; i++) a[i] = Integer.parseInt(ss[i - 1]);
        dfs(1, 0);
        writer.write(ans + "\n");
        writer.flush();
    }

    private static void dfs(int start, int cnt) {
        //如果已经放弃的大于需要放弃的，进行剪枝
        if (cnt > m) return;
        if (start == n + 1) {
            //找到一个合法的选择状态，尝试dp
            if (cnt == m) dp();
            return;
        }
        dfs(start + 1, cnt);
        st[start] = true;
        dfs(start + 1, cnt + 1);
        st[start] = false;
    }

    private static void dp() {
        int sum = 0;
        Arrays.fill(f, false);
        for (int i = 1; i <= n; i++) sum += st[i] ? 0 : a[i];
        f[sum] = true;
        for (int i = 1; i <= n; i++) {
            if (st[i]) continue;
            for (int j = 0; j <= sum - a[i]; j++) {
                f[j] |= f[j + a[i]];
            }
        }
        int res = 0;
        for (int j = 1; j <= sum; j++) {
            if (f[j]) {
                res++;
            }
        }
        ans = Math.max(res, ans);
    }
}
